﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;

namespace WXYW
{
    public partial class AccordingToProblemType : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindDropDownList();
            }
        }

        private void BindDropDownList()
        {
            for (int startYear = 2010; startYear <= DateTime.Now.Year; startYear++)
            {
                yearDropDownList.Items.Add(new ListItem(startYear.ToString(), startYear.ToString()));
            }

            for (int month = 1; month <= 12; month++)
            {
                monthDropDownList.Items.Add(new ListItem(month.ToString(), month.ToString()));
            }

            yearDropDownList.SelectedValue = DateTime.Now.Year.ToString();
            monthDropDownList.SelectedValue = DateTime.Now.Month.ToString();
        }

        protected void searchButton_Click(object sender, EventArgs e)
        {
            BindRecords();
        }

        private void BindRecords()
        {
            ApplicationProductService prodcutservice = new ApplicationProductService();
            recordsRepeater.DataSource = prodcutservice.GetMaintainRecordsByProductType(productTypeTextBox.Text, yearDropDownList.SelectedValue, monthDropDownList.SelectedValue);
            recordsRepeater.DataBind();
        }

    }
}
